package com.example.testrssparser;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class ErrorDialog extends DialogFragment  {
	
	
	private String msg;
	public ErrorDialog(String msg) {
		super();
		this.msg = msg;
	}

	// Use this instance of the interface to deliver action events
    public interface ErrorDialogListener {
    	public void onDialogErrorClick(DialogFragment dialog);
	}
	
    ErrorDialogListener mListener;
    
	@Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        // Instantiate the NoticeDialogListener so we can send events to the host
        mListener = (ErrorDialogListener) activity;
    }
	
	@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the Builder class for convenient dialog construction
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        //activity;
        builder.setMessage(msg)
        		.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       mListener.onDialogErrorClick(ErrorDialog.this);
                   }
               });
        // Create the AlertDialog object and return it
        return builder.create();
    }

}
